<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>产品兑换</title>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css">
		<link rel="stylesheet" href="style/css/add_address.css" />
		<link rel="stylesheet" href="style/css/settlement.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
		<script src="style/citypicker/js/common.js"></script>
		<script src="style/citypicker/js/Popt.js"></script>
		<script src="style/citypicker/js/cityJson.js"></script>
		<script src="style/citypicker/js/citySet.js"></script>
		<style>
			.manzeng{
				color:#F0AD4E;
				font-size:13px;
				padding-left:10px;
				margin-top:10px;
			}
		</style>
	</head>

	<body>
		<div id="settle">
		    <div id="header">
				<span class="backicon"></span>
				<h1>产品购买</h1>
			</div>
			<div class="body">
				<!--<div class="my_intergral">
					<h2>我的积分：2560</h2>
				</div>-->  
				<div class="cart">
					<ul>
						<li v-for="(good,index) in goodMsg">
							<div class="shop_info">
								<div class="shop_info_right">
									<div class="shop_info_right_top">
										<div class="shop_info_img">
											<a href="#"><img :src="good.img"></a>
										</div>
										<div class="shop_info_text">
											<h4>{{good.title}}</h4>
											<div class="shop_pices">￥<b class="price">{{good.price}}</b><b class="num fr">x{{good.num}}</b></div>
										</div>
	
									</div>
								</div>
							</div>
						</li>
	
					</ul>
					<p class="manzeng" v-if="activeMsg.status==1">{{activeMsg.title}}：满{{activeMsg.over_num}}瓶赠{{activeMsg.present_num}}瓶</p>
				</div> 
				<div class="otherinfo">
					<ul>
						<li>
							<span class="fl">工单号</span>
							<input type="text" name="text" placeholder="请输入工单号" v-model="gongdan"/>
						</li>
						<li>
							<span class="fl">收货人</span>
							<input type="text" name="text" placeholder="收货人姓名" v-model="revname"/>
						</li>
						<li>
							<span class="fl">手机号</span>
							<input type="text" name="text" placeholder="收货人手机号" v-model="revphone"/>
						</li>
						<li data-role="page" id="test">
							<div class="ui-content">
								<div data-role="listview">
									<div>
										<span class="fl">所在地区</span>
										<input type="text" name="city" placeholder="所在地区" id="city" readonly/>
									</div>
								</div>
							</div>
						</li>
						<li>
							<span class="fl">详细地址</span>
							<input type="text" name="text" placeholder="如道路、门牌号、小区等" v-model="addr"/>
						</li>
					</ul>
				</div>
				<div  class="exchange maxwidth">
					<a href="javascript:void(0);" class="text_right">合计：<b class="total_color">￥{{this.allprice.toFixed(2)}}</b></a>
					<a href="javascript:;" class="exchange_btn" @tap="jumpsuccess"><span class="pay">提交订单</span></a>
				</div>
			</div>	
		</div> 
        <script>
        	
        	
			new Vue({
        		el:"#settle",
        		data:{
        			goodMsg:"",
        			cartcan:"",
        			addr:"",
        			allprice:0,
        			htp:"",
        			gongdan:"",
        			cartnum:"",
        			ticket:"",
				    sign:"",
				    revname:"",
				    revphone:"",
				    activeMsg:"",
				    actId:""
        		},
        		methods:{
        			jumpsuccess:function(){
        				var a=sessionStorage.getItem("province");
        				var b=sessionStorage.getItem("city")
        				var c=sessionStorage.getItem("county")
        				console.log(this.cartcan,this.goodMsg)
        				var that=this
						mui.ajax(domain+"/order/create?t="+that.ticket+"&sign="+that.sign,{  
					    	dataType:"json",  
					    	type:"post", 
					    	data:{
					    		good_info:that.cartcan,
					    		form_no:that.gongdan,
					    		accept_name :that.revname,
					    		accept_phone:that.revphone,
					    		province_id:a,
					    		city_id:b,
					    		area_id:c,
					    		address:that.addr,
					    		cart:that.cartnum,
					    		active_id:that.actId
					    	},
					    	timeout:10000,
					    	headers:{'Content-Type':'application/json'},
					    	success:function(data){ 
					    		console.log(data)
//					    		alert(data.data.order_no)
					    		if(data.code==1){
						    	    mui.toast(data.msg)
//						    	    mui.openWindow({
//										url: "account.html",
//										id: "account",
//										extras:{
//											current:data.data.order_no,
//											totalPri:that.allprice
//										},
//										show: {
//											autoShow: true, //页面loaded事件发生后自动显示，默认为true
//											aniShow: "slide-in-right", //页面显示动画，默认为slide-in-right；
//											duration: 200 //页面动画持续时间，Android平台默认100毫秒，iOS平台默认200毫秒；
//										},
//										createNew:true,
//										waiting:{
//									        autoShow:false//自动显示等待框，默认为true
//									        
//								        }
//									}) 
					    		}else{
					    			mui.toast(data.msg)
					    		} 
					    	},
					    	error:function(xhr,type,errorThrown){
					    		console.log(type)           
					    	} 
					    }) 
        			}
        		},
        		created:function(){
	        			this.ticket=localStorage.getItem("tick")
	                    this.sign=localStorage.getItem("sig")
	                    this.$http.post(domain+"/order_active/getOne?t="+this.ticket+"&sign="+this.sign,{emulateJSON:true}).then(//获取轮播图
				            function (res) {
				                // 处理成功的结果
				                if(res.body.code==1){
				                  this.activeMsg=res.body.data
				                  this.actId=res.body.data.id;
				                } 
				            },function (res) {
				            // 处理失败的结果
				            console.log(res) 
				            }
				        );
        		},
        		mounted:function(){
        		
	        			this.htp=domain2
	        			this.cartcan=localStorage.getItem("canshu")
	        			console.log(this.cartcan)
	        			this.goodMsg=JSON.parse(localStorage.getItem("goodmsg"))
	        			localStorage.removeItem("canshu")
	        			localStorage.removeItem("goodmsg")
	        			for(i=0;i<this.goodMsg.length;i++){
	        				this.allprice+=(parseFloat(this.goodMsg[i].price)*parseFloat(this.goodMsg[i].num))
	        			}
	        			var that=this;
	        			mui.plusReady(function(){
	        				that.cartnum=plus.webview.currentWebview().current
	//      				alert(that.cartnum)
	        			})


        		}
        })
        	
        </script>
	</body>

</html>